package com.mapfinal.portal.template;

import java.io.File;

import com.jfinal.kit.PathKit;
import com.lambkit.core.aop.AopKit;
import com.mapfinal.gis.model.GisMap;

public class TemplateManager {

	private static TemplateManager manager = null;
	
	public static TemplateManager me() {
		if(manager==null) {
			manager = AopKit.singleton(TemplateManager.class);
		}
		return manager;
	}
	
	private String templatePath = "/templates";
	private String templateName = "default";
	
	public void init(GisMap map) {
		this.templateName = map.getTemplate();
	}
	
	public String getWebPath() {
		return templatePath + "/" + templateName;
	}
	
	public String getWebPath(String file) {
		return templatePath + "/" + templateName + "/" + file;
	}
	
	public String getFilePath(String file) {
		return PathKit.getWebRootPath() + templatePath + File.separator + templateName + File.separator + file;
	}
	
	public String getTemplatePath() {
		return templatePath;
	}

	public void setTemplatePath(String templatePath) {
		this.templatePath = templatePath;
	}

	public String getTemplateName() {
		return templateName;
	}

	public void setTemplateName(String templateName) {
		this.templateName = templateName;
	}
}
